// index.js
// 获取应用实例
const app = getApp()
const db = wx.cloud.database()

Page({
  data: {
    indicatorDots: true,
    autoplay: true,
    interval: 5000,
    duration: 1000,
    imgUrls: [] || ['/images/haibao1.png', '/images/haibao2.png', '/images/haibao3.png'],
    hotList: [],
    promotionList: [{
        id: 4,
        listPic: '/images/promotion/miaosha1.jpg',
        goodsName: '微信小程序零基础开发入门',
        goodsPrice: 9.9
      },
      {
        id: 5,
        listPic: '/images/promotion/miaosha2.jpg',
        goodsName: '微信小程序开发快速入门',
        goodsPrice: 19.9
      },
      {
        id: 6,
        listPic: '/images/promotion/miaosha3.jpg',
        goodsName: '微信小程序运营与推广自学手册',
        goodsPrice: 7.9
      }
    ],
    rotationList: []
  },
  onLoad() {
    const baseUrl = 'http://192.168.81.253:10001/'
    wx.request({
      url: baseUrl + 'prod-api/api/metro/rotation/list',
      success: ({
        data: {
          rows
        }
      }) => {
        this.setData({
          rotationList: rows,
          imgUrls: rows.map((item) => baseUrl + item.advImg)
        })
      }
    })
    console.clear()

    wx.cloud.database().collection('hotList').get({
      success: ({ data }) => {
        this.setData({ hotList: data })
      },
    })

  },

})